﻿#include "widget.h"
#include "./ui_widget.h"
#include "TestThread.h"
#include "handler/QBreakpadHandler.h"
#include "qdatetime.h"
#include "qtimer.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QBreakpadHandler handler;
    qDebug()<<"button click:"<<QString::fromStdString(handler.helloworld());
    crash();
}

void Widget::crash()
{
    srand(QDateTime::currentDateTime().timeSpec());
    TestThread t1(false, rand());
    TestThread t2(true, rand());

    t1.start();
    t2.start();

    QTimer::singleShot(3000, qApp, SLOT(quit()));
}

void Widget::uploadDumps()
{
    QBreakpadInstance.sendDumps();
}
